package com.bangdream.michelia.view.adapter;


import android.text.Html;
import android.widget.ImageView;

import com.bangdream.michelia.R;
import com.bangdream.michelia.entity.SignUpBean;
import com.bangdream.michelia.entity.TeacherBean;
import com.bangdream.michelia.utils.ImageLoadUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

/**
 * Created by zhouyi on 2018/3/25.
 */

public class TaskSignUpAdapter extends BaseQuickAdapter<SignUpBean, BaseViewHolder> {
    public TaskSignUpAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, SignUpBean item) {
        ImageLoadUtils.ImageLoad(mContext, item.getCover(), (ImageView) helper.getView(R.id.ivLogo), -1);

        helper.setText(R.id.tvNumber, "订单编号:" + item.getOrgid());
        helper.setText(R.id.tvMoney, item.getCost() + "");
        helper.setText(R.id.tvTitle, item.getName() + "");
        helper.setText(R.id.tvStudyNumber, item.getUserCnt() + "人已学习");
        helper.setText(R.id.tvTime, item.getUpdateDate() + "");

        //0：未支付 1：已支付 2：取消
        String payState = item.getPaystate();
        if (payState != null) {
            helper.setVisible(R.id.tvState,true);
            if (payState.equals("0")) {
                helper.setText(R.id.tvState, "未付款");
                helper.setTextColor(R.id.tvState, mContext.getResources().getColor(R.color.text_color));
                helper.setGone(R.id.btnCancel, false);
                helper.setText(R.id.btnGo, "去支付");

            } else if (payState.equals("1")) {
                helper.setText(R.id.tvState, "已付款");
                helper.setTextColor(R.id.tvState, mContext.getResources().getColor(R.color.text_red));
                helper.setGone(R.id.btnCancel, true);
                helper.setText(R.id.btnGo, "开始学习");
            }
        }else{
            helper.setText(R.id.btnGo, "开始学习");
            helper.setVisible(R.id.tvState,false);
            helper.setGone(R.id.btnCancel, false);
        }

        helper.addOnClickListener(R.id.btnGo);
    }
}
